Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: return fake version for performance.timeOrigin #515

Merged
merged 3 commits into from
Dec 5, 2024

Conversation

rriski
Copy link
Contributor

@rriski rriski commented Dec 3, 2024

Fixes #514

Purpose (TL;DR) - mandatory

Return valid value for performance.timeOrigin instead of NOOP. This fixes an issue in tests that depend on performance.timeOrigin having a valid value.

Background (Problem in detail) - optional

See #514

Solution - optional

Set performance.timeOrigin to a dummy value. I'm not sure if 0 is better than setting the value to clock.now. When testing performance.timeOrigin in Chrome Console I can see that the value is set to the timestamp when the window was opened:

> globalThis.performance.timeOrigin
1733227796841

There is further information in MDS docs on how the value is supposed to be set: https://developer.mozilla.org/en-US/docs/Web/API/Performance/timeOrigin#value

@fatso83
Copy link
Contributor

fatso83 commented Dec 4, 2024

This seems like a nice addition, but clock.now seems like a better fit with the docs for that prop.

src/fake-timers-src.js Outdated Show resolved Hide resolved
@rriski rriski force-pushed the support-performance-timeOrigin branch from aa0a107 to c67caa6 Compare December 5, 2024 07:32
@fatso83 fatso83 merged commit ff8d907 into sinonjs:main Dec 5, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support performance.timeOrigin property
2 participants